var _window = $(window), _windowW = _window.width(), _windowH = _window.height(); var _isFinish, _isTime; /* header */ var cy_header = function () { var _cyHeaderReal = $('.cy-header-real'), _cyNav = $('.cy-nav'), _cyNavTitle = $('.cy-nav-title ul'), _cyNavCont = $('.cy-nav-cont'), _cyNavCList = $('.cy-nav-cList'); // _cyNav.hoverIntent({ // over: function () { // }, // out: function () { // _cyNavCont.slideUp(); // _cyNavTitle.find('li').removeClass('cy-active'); // _cyIsTitle(); // } // }); _cyNav.on("mouseleave",function(){ _cyNavCont.slideUp(); _cyNavTitle.find('li').removeClass('cy-active'); _cyIsTitle(); }); _cyIsTitle(); function _cyIsTitle() { _cyNavTitle.find('li').each(function () { var _this = $(this); if($('.cy').attr('data-cy') == _this.attr('class')) { _this.addClass('cy-active').siblings().removeClass('cy-active'); } }); } // _cyNavTitle.hoverIntent({ // over: function () { // _cyNavCont.slideDown(); // }, // out: function () {} // }); _cyNavTitle.on("mouseenter",function(){ _cyNavCont.stop(false, false).slideDown(); }); _cyNavTitle.find('li').each(function () { var _this = $(this), _index = _this.index(); // _this.hoverIntent({ // over: function () { // _this.addClass('cy-active').siblings().removeClass('cy-active'); // _cyNavCList.eq(_index).addClass('cy-active').siblings().removeClass('cy-active'); // }, // out: function () {} // }); _this.on("mouseenter",function(){ _this.addClass('cy-active').siblings().removeClass('cy-active'); _cyNavCList.eq(_index).addClass('cy-active').siblings().removeClass('cy-active'); }); }); _cyNavCList.each(function () { var _this = $(this), _index = _this.index(); // _this.hoverIntent({ // over: function () { // _this.addClass('cy-active').siblings().removeClass('cy-active'); // _cyNavTitle.find('li').eq(_index).addClass('cy-active').siblings().removeClass('cy-active'); // }, // out: function () {} // }); _this.on("mouseenter",function(){ _this.addClass('cy-active').siblings().removeClass('cy-active'); _cyNavTitle.find('li').eq(_index).addClass('cy-active').siblings().removeClass('cy-active'); }); }); }; var cy_headerP = function () { var _cyNavTList = $('.cy-nav-title>ul>li'), _cyNavCList = $('.cy-nav-cList'), _cyMore = $('.cy-more'), _cyNav = $('.cy-nav'), _cyLogo = $('.cy-logo'); if ($('.cy-lm').length === 0) { _cyNav.before("
"); _cyLogo.prependTo('.cy-lm'); _cyMore.appendTo('.cy-lm'); _cyNav.append(""); _isFinish = true; _cyMore.find("a").on({click:function(e){ e.preventDefault; }}) } _cyMore.on({ click: function () { var _this = $(this); if (_isFinish) { _this.addClass('cy-active'); $('.cy-nav-mark').show(); _cyNav.addClass('cy-active'); _cyStop(); _isFinish = false; } else { _this.removeClass('cy-active'); $('.cy-nav-mark').hide(); _cyNav.removeClass('cy-active'); _cyMove(); _isFinish = true; } } }); _cyNavTList.eq(0).addClass('cy-hp-active'); _cyNavTList.each(function (index) { var _this = $(this); if (_this.find('.cy-nav-cLink').length === 0) _this.append(_cyNavCList.eq(index).html()); if(!_this.hasClass('cy-hp-active')){ _this.children('a').removeAttr('href'); } _this.children('a').click(function () { _this.addClass('cy-active').find('.cy-nav-cLink').slideDown(); _this.siblings().removeClass('cy-active').find('.cy-nav-cLink').slideUp(); }); }); }; function cy_headerShow() { var _cyLm = $('.cy-lm'), _cyNavMark = $('.cy-nav-mark'), _cyHeader = $('.cy-header'), _chHeaderReal = $('.cy-header-real'); if ($(window).width() < 1025) { cy_headerP(); } else if ($(window).width() >= 1025 || _cyLm.length > 0) { $('.cy-nav').removeClass('cy-active'); $('.cy-logo').prependTo('.cy-header-real'); $('.cy-more').appendTo('.cy-header-real').removeClass('cy-active'); _cyLm.remove(); _cyNavMark.remove(); $('.cy-nav-title>ul>li').find('.cy-nav-cLink').remove(); cy_header(); } _cyHeader.height(_chHeaderReal.height()); $(window).scroll(function () { if ($(window).scrollTop() > 0) { _chHeaderReal.addClass('cy-fixed'); } else { _chHeaderReal.removeClass('cy-fixed'); } }); } var _preventDefault = function (e) { e.preventDefault(); }; /* 绂佹婊戝姩 */ function _cyStop() { document.body.style.overflow = 'hidden'; document.addEventListener("touchmove", _preventDefault, false);//绂佹椤甸潰婊戝姩 } /* 鍙栨秷婊戝姩闄愬埗 */ function _cyMove() { document.body.style.overflow = '';//鍑虹幇婊氬姩鏉 document.removeEventListener("touchmove", _preventDefault, false); } /* header end */ /* footer */ var cy_footer = function () { var _cyContactWay = $('.cy-contact-way'), _cyFriendlyLink = $('.cy-friendlyLink>span'); var _address = _cyContactWay.find('.cy-address').find('a'), _phone = _cyContactWay.find('.cy-phone').find('a'), _email = _cyContactWay.find('.cy-email').find('a'); _address.attr("href", "http://map.baidu.com/?newmap=1&ie=utf-8&s=s%26wd%3D" + _address.text()); _phone.attr("href", "tel:" + _phone.text()); _email.attr("href", "mailto:" + _email.text()); _isFinish = true; _cyFriendlyLink.on({ click: function () { var _this = $(this).parent('.cy-friendlyLink'); if (_isFinish) { _this.find('ul').slideDown(); _isFinish = false; } else { _this.find('ul').slideUp(); _isFinish = true; } } }); }; /* footer end */ /* inside pages common content */ var _cyInsidePages = function () { var _cyIPCNav = $('.cy-iPC-nav'); _cyIPCNavFixed(_cyIPCNav); _window.scroll(function () { _cyIPCNavFixed(_cyIPCNav); }); function _cyIPCNavFixed(_ele) { var _cyScrollTop = $(window).scrollTop(), _cyOffsetTop = _ele.offset().top, _cyHeaderHeight = $('.cy-header').height(); if (_cyScrollTop > _cyOffsetTop - _cyHeaderHeight) { _ele.addClass('cy-fixed') .css('height', _ele.children().height()) .children().addClass('cy-fixed') .css('top', _cyHeaderHeight); } else { _ele.removeClass('cy-fixed') .css('height', '') .children().removeClass('cy-fixed') .css('top', ''); } } }; /* inside pages common content end */ // ajax to add common style // $.ajax({ // url: "../chengyuRe/common.header.cy.html", // success: function (result) { // $('.cy-header').html(result); // $.ajax({ // url: "../chengyuRe/common.footer.cy.html", // success: function (result) { // $('.cy-footer').html(result);*/ // _cyCommonShow(); // _cyStellar($('.cy-header').height()); // if($('.cy').attr('data-cy-common')){ // _cyInsidePages(); // } // if(navigator.userAgent.indexOf("MSIE") != -1) { // $('head').append(""); // } // } // }); // } // }); /* common function to show */ _cyCommonShow(); function _cyCommonShow() { cy_headerShow(); _window.on("resize",function () { cy_headerShow(); }); cy_footer(); } function _cyStellar(_vOffset) { var _cyIPCBGImg = $('.cy-iPC-bg img'), _cyIPCBGSpan = $('.cy-iPC-bg span'); _cyIPCBGSpan.css({ "backgroundImage": "url(./" + _cyIPCBGImg.attr('src') + ")" }); $.stellar({ horizontalScrolling: false, verticalOffset: _vOffset }); } /* common function to show end */ // 閿氱偣婊氬姩 function setScroll(anchorCur) { jQuery("html,body").animate({ scrollTop: jQuery(anchorCur).offset().top- - $('.cy-header').height() - $('.cy-iPC-nav').height()}, 200); } window.onload = function () { var hash = location.href.split("#")[1]; if (hash) { setScroll("#" + hash); } };